<table class="dic-list" data-page="${page!'1'}" data-count="${count!'0'}" data-page-size="${pageSize!'30'}">
	<tr class="title-row">
		<th class="text-center" width="60">序号</th>
		<th class="text-center" width="130">说明</th>
		<th>值</th>
	</tr>
	<#if data??> <#list data as dic>
	<tr data-id="${dic.id}" class="for-click ${(dic.system)?string('system-dic','')}" style="cursor: pointer;">
		<td class="text-center">${dic.sort}</td>
		<td class="text-center ${(dic.system)?string('text-danger','')}">${(dic.system)?string('系统（禁止删除）','自定义')}</td>
		<td>${dic.val}</td>
	</tr>
	</#list> </#if>
</table>

<script src="${request.contextPath}/js/suredy-list.js"></script>
<script type="text/javascript">
	$(function() {
		$('table.dic-list').list({
			search : false,
			header : true,
			footer : false,
			checkbox : true,
			btns : [ {
				text : '增加',
				icon : 'icon-plus',
				style : 'btn-primary btn-sm',
				click : function(page, pageSize, key) {
					$.suredy.showModal({
						icon : 'icon-plus',
						title : '增加字典项',
						showFoot : false,
						uri : '${request.contextPath}/config/dictionary/add-form/${groupCode}'
					});
				}
			}, {
				text : '删除',
				icon : 'icon-minus',
				style : 'btn-danger btn-sm',
				click : function(page, pageSize, key) {
					var checked = $.suredy.list.checked($('table.dic-list'));

					if (checked.length <= 0) {
						alert('请勾选需要删除的项');
						return false;
					}

					var ids = [];

					checked.each(function(i) {
						var $this = $(this);

						ids[ids.length] = $this.data('id');
					});

					$.ajax({
						url : '${request.contextPath}/config/dictionary/del',
						data : {
							ids : ids
						},
						type : 'post',
						dataType : 'json',
						success : function(data) {
							if (!data || !data.success) {
								alert(data.msg || '删除失败！');
								return false;
							}

							$.suredy.loadContent('${request.contextPath}/config/dictionary/list/${groupCode}');
						},
						error : function() {
							alert('删除失败！');
						}
					});
				}
			} ]
		});

		// 排除系统配置
		$('table.dic-list .system-dic').removeClass('content-row');
		$('table.dic-list .system-dic .row-checkbox').remove();

		$('tr.for-click').on('click', function(event) {
			var $this = $(this);
			var id = $this.data('id');

			$.suredy.showModal({
				icon : 'icon-edit',
				title : '修改字典项',
				showFoot : false,
				uri : '${request.contextPath}/config/dictionary/edit/' + id
			});
		});
	});
</script>